package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/13
 * Time: 17:29
 * Description: No Description
 */
public class Find implements IOperation{

    public void work(BookList booklist) {
        System.out.println("查找图书");

        System.out.println("请输入查找的书名：");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int index = booklist.getCount();
        for (int i = 0; i < index; i++) {
            Book book = booklist.getBook(i);
            if(name.equals(book.getName())) {
                System.out.println("找到了,图书信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("抱歉,没有找到");
    }
}